CC = g++ -Wall -std=c++17 -fPIC
RELEASE = 0
UNICODE = 0
INCLUDE = -I ./
FILECENTOS = /etc/redhat-release
LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib
LIB = -lXEngine_BaseLib -ljsoncpp
LIBEX = -static-libgcc -lrt -ldl 
LOADSO = -Wl,-rpath=,--disable-new-dtags
LIBINCLUDE = Protocol_P2XPPacket.o Protocol_StoragePacket.o Protocol_P2XPParse.o Protocol_StorageParse.o pch.o

ifeq ($(RELEASE),1)
FLAGS = -c -O2 
DEBUG = 
else
FLAGS = -c -lc_p
DEBUG = -g -pg 
endif

ifeq ($(UNICODE),1)
UNICODE = -D _UNICODE
else
UNICODE = 
endif

ifeq ($(FILECENTOS), $(wildcard $(FILECENTOS)))
	UNICODE = -D _CENTOS
else
	UNICODE = -D _UBUNTU
endif

all:$(LIBINCLUDE)
	$(CC) $(DEBUG) $(LIBINCLUDE)  -o libStorageModule_Protocol.so -shared $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO)

Protocol_P2XPPacket.o:./Protocol_Packet/Protocol_P2XPPacket.cpp                                 
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE)  ./Protocol_Packet/Protocol_P2XPPacket.cpp  
Protocol_StoragePacket.o:./Protocol_Packet/Protocol_StoragePacket.cpp                                 
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE)  ./Protocol_Packet/Protocol_StoragePacket.cpp 
Protocol_P2XPParse.o:./Protocol_Parse/Protocol_P2XPParse.cpp                                 
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE)  ./Protocol_Parse/Protocol_P2XPParse.cpp 
Protocol_StorageParse.o:./Protocol_Parse/Protocol_StorageParse.cpp                                 
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE)  ./Protocol_Parse/Protocol_StorageParse.cpp 
	
pch.o:pch.cpp             
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) pch.cpp


InstallAll:InstallSo 
InstallSo:./libStorageModule_Protocol.so
	cp ./libStorageModule_Protocol.so ../../XEngine_Release/libStorageModule_Protocol.so


CleanAll:CleanObj CleanMk
CleanObj:
	rm *.o                                           
CleanMk:
	rm *.so    
